package com.starking.wxx.http;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import sun.net.www.http.HttpClient;

import java.io.IOException;
import java.io.UnsupportedEncodingException;

/**
 * @描述:
 * @文件名: K2Finish.java
 * @创建人: wangxinxin
 * @创建时间: 2018/12/28
 * @修改人: wangxinxin
 * @修改备注: <br/>
 * <p>
 */
public class K2Finish {

    public static void main(String[] args) {

        String url = "http://bpm.58corp.com/k2interface/updateStatus";
        CloseableHttpClient httpclient = HttpClients.createDefault();
        HttpPost httpPost = new HttpPost(url);

        try {
            String postData = "{\"sn\":\"2100-D001-XZ-00108484\",\"flag\":\"2\"}";
            httpPost.setEntity(new StringEntity(postData));
            CloseableHttpResponse httpResponse = httpclient.execute(httpPost);
            String resultString = EntityUtils.toString(httpResponse.getEntity(), "utf-8");
            System.out.println(resultString);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
